package guess;

import java.util.Scanner;

public class Game {
	Scanner scan = new Scanner(System.in);
	
	int playWinCount = 0;			//���Ӯ�Ĵ���
	int computerWinCount = 0;   //����Ӯ�Ĵ���
	int drawCount = 0;				//ƽ�ִ���
	int per = 0; 							//��ҳ�����
	int pc = 0;								//���Գ�����
	/**
	 * ��Ϸ��ʼ
	 */
	public void start() {
		/*
		 *��ȭ��Ϸ 0---ʯͷ 1---���� 2---�������ͨ����������һ��0--2������ʾ��ҳ�ȭ
		 * ����ͨ��ϵͳ�������һ��0--2������ʾ���Գ�ȭ 
		 * ˼������������Ӯ���Ǽ����Ӯ������ʾ����������ҵĴ������룩 
		 */
		System.out.println("*************************************************************");
		System.out.println("                          ��ӭ�����ȭ��Ϸ"); 
		System.out.println("*************************************************************");
		do {
			player();
			computer();
			win();
			System.out.println("�Ƿ������Y/N");
		}while("Y".equalsIgnoreCase(scan.next()));
		showResult();
	}
	/**
	 * ��ҳ���
	 */
	public void player() {
		System.out.println("��ȭ��Ϸ�� 0---ʯͷ ��1---���� �� 2---�� �����·�������ĳ�ȭ��"); 
		per = scan.nextInt();
		switch(per)  { 
		case 0: 
			System.out.println("�������ǣ�ʯͷ");
			break; 
		case 1: 
			System.out.println("�������ǣ�����");
			break; 
		case 2: 
			System.out.println("�������ǣ���");
			break; 
		default: 
			System.out.println("�������벻��ȷ�����������룡");
			player();
		} 
	}

	/**
	 * ���Գ���
	 */
	public void computer() {
		pc = (int)(Math.random()*3); //������� 0 1 2 
		switch(pc)  { 
		case 0: 
			System.out.println("���Գ����ǣ�ʯͷ");
			break; 
		case 1: 
			System.out.println("���Գ����ǣ�����");
			break; 
		case 2: 
			System.out.println("���Գ����ǣ���");
			break; 
		} 
	}

	/**
	 * �ж���Ӯ
	 */
	public void win() {
		boolean flag = true; 
		if(flag == true) { 
			if(per==pc)  { 
				drawCount++;
				System.out.println("���Ǹ�ƽ��Ŷ��"); 
			} 
			else if(per==0&&pc==1||per==1&&pc==2||per==3&&pc==0)  { 
				playWinCount++;
				System.out.println("��ϲ�㣬��Ӯ�ˣ�"); 
			} else  { 
				computerWinCount++;
				System.out.println("�����ˣ����ٽ�������"); 
			} 
		} 
	}

	/**
	 * ��ʾ���ս��
	 */
	public void showResult() {
		System.out.println("����һ��Ӯ��" + computerWinCount + "��");
		System.out.println("��һ��Ӯ��" + playWinCount + "��");
		System.out.println("ƽ��" + drawCount + "��");
	}
	public static void main(String[] args) {
		Game game = new Game();
		game.start();
	}
}
